package com.bascker.algorithm.practice.sliding_window.easy.find_max_consecutive_one;

import java.util.Objects;

// 暴力枚举, 时间复杂度：O(n^2)
public class Solution1 {

    public int findMaxConsecutiveOnes(int[] nums) {
        int max = 0;
        if (Objects.isNull(nums) || nums.length < 1) {
            return max;
        }

        int n = nums.length;
        for (int i = 0; i < n; i++) {
            if (nums[i] == 0) {
                continue;
            }

            int count = 0;
            for (int j = i; j < n; j++) {
                // 1 不连续时，打破内层循环
                if (nums[j] != nums[i]) {
                    break;
                }

                count++;
            }

            max = Math.max(max, count);
        }

        return max;
    }

}
